package com.aiju.cash.ui.pay;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.aiju.base.activity.BaseTitleActivity;
import com.aiju.cash.R;
import com.aiju.cash.ui.billing.BillingActivity;
import com.aiju.cash.ui.main.BlotterInfoActvity;
import com.aiju.cash.ui.main.MainActivity;

/**
 * @author: 佐为
 * @date: 2017-04-24 10:07
 * @version: V1.0
 * @Description: 打印失败
 */
public class PrintErrorActivity extends BaseTitleActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_print_error);
        setCenterTitle("打印失败");
        setRightTitle("查看流水");

        mAiJuTitleBarView.setRightOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String serialNum = getIntent().getStringExtra("serialNum");
                Intent intent = new Intent(PrintErrorActivity.this, BlotterInfoActvity.class);
                intent.putExtra("id", serialNum);
                intent.putExtra("type", 1);
                intent.putExtra("title", "流水详情");
                intent.putExtra("refund", 1);
                startActivity(intent);
            }
        });

        String msg = getIntent().getStringExtra("msg");
        if (!TextUtils.isEmpty(msg)) {
            ((TextView) findViewById(R.id.tv_print_msg)).setText(msg);
        }

        findViewById(R.id.btn_pay_go).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(PrintErrorActivity.this, BillingActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        });

    }

    @Override
    public void onBackPressed() {
        Intent intent = new Intent(this, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }
}
